<?php

require_once 'PHPUnit/Extensions/ExceptionTestCase.php';
jClasses::inc('cube~Edge');

class UTEdge extends PHPUnit_Extensions_ExceptionTestCase 
{
    // Test of the limits of the Cubie construct
    public function testConstructOK() 
    {
        try 
        {
            $myEdge = new Edge(0);
        }
        catch (Exception $e) {$this->fail();}

        try 
        {
            $myEdge = new Edge(0, 0);
        }
        catch (Exception $e) {$this->fail();}

        try 
        {
            $myEdge = new Edge(0, 1);
        }
        catch (Exception $e) {$this->fail();}
    }

    public function testConstructKO1() 
    {
        $this->setExpectedException('Exception');
        $myEdge = new Edge(Edge::MAX_EDGE + 1);
    }

    public function testConstructKO2() 
    {
        $this->setExpectedException('Exception');
        $myEdge = new Edge(-1);
    }

    public function testConstructKO3() 
    {
        $this->setExpectedException('Exception');
        $myEdge = new Edge("stupid param");
    }

    public function testConstructKO4() 
    {
        $this->setExpectedException('Exception');
        $myEdge = new Edge(0, -1);
    }

    public function testConstructKO5() 
    {
        $this->setExpectedException('Exception');
        $myEdge = new Edge(0, 2);
    }

    public function testGetOrientation() 
    {
        $myEdge = new Edge(0, 0);
        $this->assertTrue($myEdge->getOrientation() === 0);
        $myEdge = new Edge(0, 1);
        $this->assertTrue($myEdge->getOrientation() === 1);
    }

    public function testToggleOrientation() 
    {
        $myEdge = new Edge(0, 0);
        $myEdge->toggleOrientation();
        $this->assertTrue($myEdge->getOrientation() === 1);
        $myEdge->toggleOrientation();
        $this->assertTrue($myEdge->getOrientation() === 0);
    }
}
?>
